package com.xszx.util;

import com.xszx.beans.User;
import com.xszx.dao.UserDao;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * @Author 信思智学
 */
public class MybatisUtil {

    public static SqlSessionFactory getSqlSessionFactory() throws IOException {
        //第一步：加载配置文件
        InputStream inputStream = Resources.getResourceAsStream("mybatis-config.xml");
        //第二步：创建核心工厂类
        SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(inputStream);

        return sessionFactory;

    }

}
